package com.hig.risk.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hig.risk.mapper.RiskHazardInvestigationMapper;
import com.hig.risk.domain.RiskHazardInvestigation;
import com.hig.risk.service.IRiskHazardInvestigationService;

/**
 * 安全生产隐患排查治理清单Service业务层处理
 * 
 * @author scp
 * @date 2024-09-29
 */
@Service
public class RiskHazardInvestigationServiceImpl implements IRiskHazardInvestigationService 
{
    @Autowired
    private RiskHazardInvestigationMapper riskHazardInvestigationMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询安全生产隐患排查治理清单
     * 
     * @param id 安全生产隐患排查治理清单ID
     * @return 安全生产隐患排查治理清单
     */
    @Override
    public RiskHazardInvestigation selectRiskHazardInvestigationById(Long id)
    {
        return riskHazardInvestigationMapper.selectRiskHazardInvestigationById(id);
    }

    /**
     * 查询安全生产隐患排查治理清单列表
     * 
     * @param riskHazardInvestigation 安全生产隐患排查治理清单
     * @return 安全生产隐患排查治理清单
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<RiskHazardInvestigation> selectRiskHazardInvestigationList(RiskHazardInvestigation riskHazardInvestigation)
    {
        return riskHazardInvestigationMapper.selectRiskHazardInvestigationList(riskHazardInvestigation);
    }

    /**
     * 新增安全生产隐患排查治理清单
     * 
     * @param riskHazardInvestigation 安全生产隐患排查治理清单
     * @return 结果
     */
    @Override
    public int insertRiskHazardInvestigation(RiskHazardInvestigation riskHazardInvestigation)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        riskHazardInvestigation.setCreateBy(loginUser.getUser().getUserName());
        riskHazardInvestigation.setDeptId(loginUser.getUser().getDeptId());
        riskHazardInvestigation.setCreateTime(DateUtils.getNowDate());
        return riskHazardInvestigationMapper.insertRiskHazardInvestigation(riskHazardInvestigation);
    }

    /**
     * 修改安全生产隐患排查治理清单
     * 
     * @param riskHazardInvestigation 安全生产隐患排查治理清单
     * @return 结果
     */
    @Override
    public int updateRiskHazardInvestigation(RiskHazardInvestigation riskHazardInvestigation)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        riskHazardInvestigation.setUpdateBy(loginUser.getUser().getUserName());
        riskHazardInvestigation.setUpdateTime(DateUtils.getNowDate());
        return riskHazardInvestigationMapper.updateRiskHazardInvestigation(riskHazardInvestigation);
    }

    /**
     * 批量删除安全生产隐患排查治理清单
     * 
     * @param ids 需要删除的安全生产隐患排查治理清单ID
     * @return 结果
     */
    @Override
    public int deleteRiskHazardInvestigationByIds(Long[] ids)
    {
        return riskHazardInvestigationMapper.deleteRiskHazardInvestigationByIds(ids);
    }

    /**
     * 删除安全生产隐患排查治理清单信息
     * 
     * @param id 安全生产隐患排查治理清单ID
     * @return 结果
     */
    @Override
    public int deleteRiskHazardInvestigationById(Long id)
    {
        return riskHazardInvestigationMapper.deleteRiskHazardInvestigationById(id);
    }
}
